{% extends "base.html" %}
{% import "_macros.html" as macros %}

{% block bottomscript %}
  {{ super() }}
  <script src="{{url_for('static', filename='dist/post.js')}}"></script>
{% endblock %}

{% block title %}{{ post.title }}{% endblock %}

{% block content %}
  {% set url = post.url() %}
  {{ macros.card(post) }}
  <div class="post-tags">
    {% for tag in post.tags %}
      <a class="btn btn-default btn-rounded btn-xs" href="{{ tag.url() }}">{{ tag.name }}</a>
    {% endfor %}
  </div>
  <div class="social-share-button text-center" data-title="不改一行代码定位线上性能问题 {{ url }} 分享自 @{{ post.author.name }}" data-type="text" data-url={{ url }}>
    <h5>分享到</h5>
    <a href="javascript:;" class="btn btn-danger" rel="external nofollow" data-site="github" onclick="return SocialShareButton.share(this);"><i class="fa fa-weibo"></i> Github</a>
    <span class="dropdown weixin-qrcode-dropdown">
      <button class="btn btn-success" id="weixin-qrcode" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-weixin"></i> 微信</button>
      <span class="dropdown-menu weixin-qrcode-dropdown-menu" aria-labelledby="weixin-qrcode" data-url="{{ url }}">
        <span class="weixin-qrcode" aria-labelledby="weixin-qrcode" data-url="{{ url }}"><canvas width="132" height="132"></canvas></span>
      </span>
    </span>
  </div>

  <div class="post-comment-form">
    <span>评论 ({{ post.n_comments }})</span>

    {% if not request.user %}
    <div class="login-actions">
      <a class="btn btn-success" href="/signin">登录后评论</a>
    </div>
    {% else %}
    <form id="comment-form" novalidate="novalidate" class="new_comment" data-url="post/{{ post.id }}/comment" accept-charset="UTF-8" method="post">
      <div class="form-group text required comment_content">
        <textarea rows="5" class="text required comment-content form-control" id="comment-content">
        </textarea>
      </div>
      <div class="text-right">
        <input type="submit" id="comment-submit" name="commit" value="提 交" class="btn btn-default btn-info">
      </div>
    </form>
    {% endif %}
  </div>

  <div id="comments" class="comments">
    {% for comment in post.get_comments(None) %}
    {{ macros.render_comment(comment) }}
    {% endfor %}
  </div>
{% endblock %}
